package com.bawei.bydayzg_two.adapter

import android.graphics.Color
import android.widget.LinearLayout
import com.bawei.base.bean.CartGoreyChild
import com.bawei.bydayzg_two.R
import com.bawei.bydayzg_two.Utils.GildUtils
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.viewholder.BaseViewHolder

class TwoAdapter:BaseQuickAdapter<CartGoreyChild,BaseViewHolder>(R.layout.item_two) {
    var index = 534
    //
    override fun convert(holder: BaseViewHolder, item: CartGoreyChild) {
        holder.setText(R.id.two_tv,item.name)
        //
        GildUtils.loadImg(context,item.extra,holder.getView(R.id.two_iv))
        //
        if (item.id == index){
            holder.getView<LinearLayout>(R.id.two_ll).setBackgroundColor(Color.RED)
        } else {
            holder.getView<LinearLayout>(R.id.two_ll).background = null
        }
    }
    //
    fun getIndex(position:Int){
        index = position
        //
        notifyDataSetChanged()
    }
}